<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
<title>${name_china}管理-编辑${name_china}</title>
<%@include file="/common/head.jsp" %>

<!-- 上传下载插件 -->
 <link href="<%=request.getContextPath()%>/static/plugin/uploadify/style/uploadify.css" rel="stylesheet">
 <script src="<%=request.getContextPath()%>/static/plugin/uploadify/js/jquery.uploadify.js"></script>

<!-- 时间日期插件 -->
<link href="<%=request.getContextPath()%>/static/plugin/My97DatePicker/skin/default/datepicker.css" rel="stylesheet" >
<script src="<%=request.getContextPath()%>/static/plugin/My97DatePicker/WdatePicker.js"></script>

<!--富文本插件 -->
<script src="<%=request.getContextPath()%>/static/plugin/ckeditor/ckeditor.js"></script>

</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
            <span class="split"></span>
            <span>编辑${name_china}</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="form" method="post">
    <div class="form-wrapper">
	  <div class="h4 distance-double">
        <span class="h4-title"><i class="icon icon-setting"></i>基本信息</span>
        <span class="h4-border"></span>
      </div>
      
      <input type="hidden" id="id" name="id"/> 
      
     <div class="form-cont">
	        <p class="form-cont-title">排序号</p>
	        <input type="text" id="reorder" name="reorder" class="summer-input summer-validatebox"  data-validatebox="validType:['noNegativeNumber']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>中文名称</p>
	        <input type="text" id="brandChinaName" name="brandChinaName" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[50]']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>英文名称</p>
	        <input type="text" id="brandEnglishName" name="brandEnglishName" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[50]']"/> 
	     </div>
	     
	      <div class="form-cont">
            <p class="form-cont-title"><!-- <span class="field-required">*</span> -->LOGO</p>
            <!-- 这里写表数据的附件字段  fileId -->
            <input id="fileUpload" name="fileId" type="text" class="summer-input distance-right">
            <label class="label-secondary "></label>
            <!-- 这里一定要写一个id隐藏 -->
            <input type="hidden" id="id" name="id"> 
         </div>
         
          <div class="form-cont">
	        <p class="form-cont-title">创建日期</p>
	        <input type="text" id="brandCreateDate" name="brandCreateDate" class="summer-input summer-validatebox"  onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" data-validatebox="validType:['maxLength[50]']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>官方网站</p>
	        <input type="text" id="brandUrl" name="brandUrl" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[300]']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">品牌简介</p>
	        <textarea class="summer-textarea" id="brandContent" name="brandContent"></textarea>
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">备注</p>
	        <textarea class="summer-textarea" id="note" name="note"></textarea>
	     </div>
	      
     
     <div class="form-btn-wrapper" id="funcbar">
        <a class="btn btn-normal" id="backBtn">关闭</a>
    </div>
  </div>
</form>
<script>
    
  var   editData,
        permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
    	//初始化funcbar
     	$('#funcbar').prepend($.funcbar({
            type: 'button',
            data: permission,
            permit: ['${name_english}:edit']
        }));
    	
    	editData = ${editData};
    	
    	createConfig();// 初始化插件
    	
        $('#form').form({
        	onLoadSuccess:function(data){
                var fileInfo = upLoadUtil.getFileInfo(editData.fileId,"FILE_ID");// 获得文件信息
                upLoadUtil.createFileList(fileInfo,"form");// 初始化文件列表
           }
        }).form('loadDataEdit', {
            data: editData
        }); 
    	
    	//保存按钮
    	$('#funcbar').on('click', 'a[data-permit="${name_english}:edit"]', submit);
    	
    	//返回按钮
    	$('#backBtn, #goBack').on('click',backMain);
    });
    
    
    //表单提交
    function submit() {
         $("#form").form({
        	 buttons : ['#saveBtn'],
             ajax: {
                 url: CONST_URL.EDIT
             },
             onSubmitSuccess: function (data) {
            	 $.stip({
   	                type:'ok',//显示类型 有info、 ok、 danger
   	                text: '保存成功！',
   	                onBeforeHide: function () {
   	                	backMain();
   	                }
            	 });
              }
         }).form("submit");
    }
    
    
    //上传初始化方法
    function createConfig(){
        var config = {
            "sessionId" : '${pageContext.session.id}',
            "formId": "form",
            "items": [
                {
                    'id' : "fileUpload",// 按钮id
                    'fileSizeLimit' : '102400000KB',// 文件大小
                    'multi' : false, // 是否多选
                    'required' : false, // 是否必填
                    'fileTypeExts' : '*.png;*.jpg;*.jpeg',//限制文件格式
                    'uploadLimit' : 1,// 上传队列最大个数
                    'tableName' : "T_MALL_CATEGORY_BRAND",// 表名
                    'field' : 'FILE_ID',// 数据库字段标识
                    'queueSizeLimit' : 1,// 每次选择文件数量
                    'hiddenFileIds' : "fileId"// 存储文件id隐藏框的name，程序自动创建
                }
            ]
        };
        upLoadUtil.initUplod(config);// 初始化上传插件
    }
    
    
    //返回主页面
    function backMain() {
    	window.location.href = CONST_URL.INIT_LIST;
    	//window.location.href = CONST_URL.INIT_MAIN;
    	//parent.refreshList(editData.id);
    }
    
    //请求url
    var CONST_URL = {
   		INIT_LIST: basePath + "${common_url}initList?categoryId=${categoryId}",
    	INIT_MAIN: basePath + "${common_url}init",
       	EDIT: basePath + "${common_url}edit"
    };
    
</script>
</body>
</html>